// src/api/userInfoAPI.js
import http from '@/utils/http'

/**
 * 添加用户
 * @param {Object} params - 用户信息对象
 */
export const addUserInfoAPI = (params) => {
  return http.post('/user-client/cms/userInfo/add', params)
}

/**
 * 修改用户资料
 * @param {number} id - 用户ID
 * @param {Object} params - 用户信息对象
 */
export const updateUserInfoAPI = (id, params) => {
  return http.post(`/user-client/cms/userInfo/update?id=${id}`, params)
}

/**
 * 删除用户
 * @param {number} id - 用户ID
 */
export const deleteUserInfoAPI = (id) => {
  return http.post(`/user-client/cms/userInfo/delete?id=${id}`)
}

/**
 * 切换用户状态
 * @param {number} id - 用户ID
 */
export const toggleUserInfoStatusAPI = (id) => {
  return http.post(`/user-client/cms/userInfo/toggleStatus?id=${id}`)
}

/**
 * 获取用户详情
 * @param {number} id - 用户ID
 */
export const getUserInfoAPI = (id) => {
  return http.post(`/user-client/cms/userInfo/get?id=${id}`)
}

/**
 * 获取所有用户信息
 */
export const listAllUserInfoAPI = () => {
  return http.post('/user-client/cms/userInfo/listAll')
}

/**
 * 根据用户名模糊匹配
 * @param {string} name - 用户名
 */
export const searchUserInfoByNameAPI = (name) => {
  return http.post('/user-client/cms/userInfo/searchByName', {}, {
    params: {
      name: name || undefined
    }
  })
}